﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace DBSourceToolsLib
{
    public class BatchRunner : ProcessRunner
    {
        private string m_OutputFileName;
        private string m_BatchFileName;
        private string m_WorkingDir;

        private List<string> m_Arguments = new List<string>();
        public BatchRunner(string strOutputFileName, string strBatchFileName, bool bReturnRunTime)
            : base(bReturnRunTime)
        {
            this.m_OutputFileName = strOutputFileName;
            this.m_BatchFileName = strBatchFileName;
            m_WorkingDir = m_BatchFileName.Substring(0,m_BatchFileName.LastIndexOf("\\") + 1);

        }

        public void SetOutputFileName(string strOutputFileName)
        {
            this.m_OutputFileName = strOutputFileName;
        }

        public override string GetWorkingDir()
        {
            return m_WorkingDir;
        }

        public override string GetFileName()
        {
            return m_BatchFileName;
            //return m_Path + "\\" + m_BatchFileName;
        }

        public override string GetArguments()
        {
            bool bNeedsSpace = false;
            StringBuilder oBuilder = new StringBuilder();
            foreach (string strArg in m_Arguments)
            {
                if (bNeedsSpace)
                    oBuilder.Append(" ");
                oBuilder.Append(strArg);
                bNeedsSpace = true;
            }
            return oBuilder.ToString();
        }

        public override string GetOutputFileName()
        {
            return m_OutputFileName;
            //return GetFileName() + "_results.txt";
        }

        public void AddArgument(string strArgument)
        {
            this.m_Arguments.Add(strArgument);
        }

        public override string GetTempFileName()
        {
            return null;
        }
        //public override string GetSQLScript()
        //{
        //    return "";
        //}

        //public override string GetScriptName()
        //{
        //    return "";
        //}
    }
}
